
<style lang="scss">
    .selectupload .ivu-form-item{
        width:100% !important;
    }
</style>
<template>
    <Form :label-width="120" inline class="selectupload">
        <compFormEdit
            ref="formdata"
            class="margin-10 padding-right-10 width-100per"
            v-if="getBase&&getBase.length"
            :formdata="getBase"
            v-model="formData"
        ></compFormEdit>
        <compUpload v-bind="getFileProps" @on-close="close" @on-success="success" :warningtitle="warningtitle"></compUpload>
        
    </Form>
</template>
<script>
import { mapGetters } from "vuex";

export default {
    props:{
        name: String, 
        formdata: Array,
        actionurl: String,
        downrul: String,
        warningtitle: String, 
        localurl:Boolean,
        showdownload:Number,
        params:null,
    },
    data(){
        return {
            formData:{...this.params},
        }
    },
    computed: {
        getBase(){
            return this.formdata
        },
        getFileProps() {
            if(this.showdownload === 1){
                return {
                    action: this.actionurl,
                    name: this.name,
                    data: {
                        ...this.formData
                    },
                }
            }else{
                return {
                    action: this.actionurl,
                    name: this.name,
                    data: {
                        ...this.formData
                    },
                    download:()=>{
                        console.log(this.localurl)
                        if(this.localurl){
                            this.handleWebfs(this.downrul, {}, {
                                executor: 'download',
                                type: 'url'
                            });
                        }else{
                            this.handleWebfs(this.downrul, 'download')    
                        }
                    }
                }
            }
			
		},
    },
    methods: {
        close(){
            this.$emit('on-close')
        },
        success(res){
            this.close()
            this.$emit('on-update')
        }
    }
}
</script>